<template>
   <el-table
    :data="tableData"
    border
    style="width: 100%">
    <el-table-column
    prop="practice.p_id"
    label="实践序号"
    width="180"
    >
    </el-table-column>
    <el-table-column
    prop="practice.p_name"
    label="实践名称"
    width="230">
    </el-table-column>
    <el-table-column
    prop="practice.address"
    label="实践地址"
    width="230">
    </el-table-column>
    <el-table-column
    prop="practice.start_time"
    label="起始时间"
    width="230">
    </el-table-column>
    <el-table-column
    prop="practice.end_time"
    label="结束时间"
    width="230">
    </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      width="110">
      <template slot-scope="scope">
        <el-button
          @click.native.prevent="deleteRow(scope.$index, tableData)"
          type="text"
          size="small">
          删除
        </el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
export default {
    data() {
      return {
        tableData: [],
        s_id:JSON.parse(sessionStorage.getItem("student")).s_id
        }
    },
    created(){
        this.$axios.post('/api/student/findmypractice',this.$qs.stringify({s_id:this.s_id})).then(res=>{
            this.tableData=res.data;
        })
    },

    
    methods: {
      deleteRow(index, rows) {
        this.$axios.post('/api/student/deletepractice',this.$qs.stringify({
          pd_id:rows[index].pd_id})).then(()=>{
            rows.splice(index, 1);
            this.$message.success('删除成功');
        }).catch(()=>{
          this.$message.error('删除失败');
        })
        
        
      }
    }
    
    }
</script>

<style>

</style>